function IR = cartesianas (I)
 [F C] = size(I);
 IR = zeros(F, C);
 Om = (F+1)/2;                  % co-ordinates of the center of the image
 On = (C+1)/2;
 sx = (F-1)/2;                  % scale factors
 sy = (C-1)/2;
 delR = 1/(F-1);
 delT = 2*pi/C;
for xi = 1:F
for yi = 1:C
    x = (xi - Om)/sx;
    y = (yi - On)/sy;
    radio = sqrt(x^2 + y^2);
    if radio >=0 && radio <=1
       theta = atan2(y,x);
       if theta < 0
           theta = theta + 2*pi;
       end
       ri = 1 + (radio)/delR;
       ti = 1 + theta/delT;
       rf = floor(ri);
       rc = ceil(ri);
       tf = floor(ti);
       tc = ceil(ti); 
       if tc > F
          tc = tf;
       end
       if rc > C
          rc = tf;
       end
       if (rf == rc && tc == tf)
          IR (xi, yi) = I (rc, tc);
       elseif (rf == rc)
          IR (xi, yi) = I (rf, tf) + (ti - tf)*(I (rf, tc) - I (rf, tf));
       elseif (tf == tc)
          IR (xi, yi) = I (rf, tf) + (ri - rf)*(I (rc, tf) - I (rf, tf));
       else
          IR (xi, yi) = I (rc,tc);
      end 
    end
end
end

